unit Con_SuperMov;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls,
  Db, DbTables, TFlatButtonUnit;

type
  TFrmCon_SuperMov = class(TFrmConsulta)
    Label1: TLabel;
    dbgSuperMov: TDBGrid;
    btnGravar: TFlatButton;
    procedure BtnFecharClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure btnGravarClick(Sender: TObject);
  private
    { Private declarations }
    procedure FazConsulta;
  public
    { Public declarations }
    Sup_Codigo: string;
    Supm_Data: TDateTime;
    Sup_Nome: string;
    Supm_Sequencia: Smallint;
  end;

var
  FrmCon_SuperMov: TFrmCon_SuperMov;

implementation
uses Dm, Biblio, clsSuperMov, Cad_SuperMov, menu;

{$R *.DFM}

var
  SuperMov: TSuperMov;
  tds: Tdatasource;
  tq: Tquery;

procedure TFrmCon_SuperMov.BtnFecharClick(Sender: TObject);
begin
  inherited;
  supm_sequencia := tq.fieldbyname('Supm_Sequencia').AsInteger;
  tds.free;
  tq.free;
end;

procedure TFrmCon_SuperMov.FormActivate(Sender: TObject);
begin
  inherited;
  if FileExists(caminho_personal + 'belquimica') then begin
    btnGravar.Visible := False;
  end;
  label1.caption := sup_nome;
  tds := TDataSource.create(FrmCon_SuperMov);
  tq := Tquery.create(FrmCon_SuperMov);
  tq.databasename := dmint.db.databasename;
  tq.active := False;
  tds.DataSet := tq;
  fazconsulta;
end;

procedure TfrmCon_SuperMov.FazConsulta;
begin
  SuperMov := TSuperMov.Create;
  SuperMov.Consultar(tq, sup_codigo, supm_data);
  tq.open;
  SuperMov.free;
  dbgSuperMov.DataSource := tds;
  dbgSuperMov.Refresh;
end;

procedure TFrmCon_SuperMov.btnGravarClick(Sender: TObject);
var
  f1: TfrmCad_SuperMov;
begin
  inherited;
  f1 := TfrmCad_SuperMov.Create(self);
  f1.btnC_SuperMov.Visible := True;
  f1.ShowModal;
  F1.Free;
  FazConsulta;
end;

end.
